Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SG-36129 Add customized sort fields #96

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pscadding
Copy link
Contributor

@pscadding pscadding commented Aug 29, 2024

Makes the My Tasks tab sort fields configurable through the yml settings.

The user can choose any fields including linked fields to sort by, assuming that they are valid fields to sort by.

The default sort options are the same as before + the step which appeared to be mostly added by possibly accidentally excluded. (Note the UI styling looks a little weird here, because I'm running out of my terminal and not a DCC)

Screenshot 2024-08-29 at 14 25 13

The user can then customise the list through the env config.

Screenshot 2024-08-29 at 14 01 33

If its configured with a non existing field it will result in an error in the console if the user picks that sort field in the list.
I'm not sure there is a better way of handling this as it asynchronous so I can't just wrap the instruction to load data in a try except.
I think in order to get a better handle on it we might need to make changed to the shotgun model.
An example of the error you would get is here:

Traceback (most recent call last):
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_query_model.py", line 945, in __on_data_retriever_work_completed
[DEBUG sgtk.env.project.tk-shell.tk-framework-shotgunutils] [ShotgunFindDataHandler] Completed save of <ShotgunFindDataHandler@/Users/~/Library/Caches/Shotgun/~/site/fw-shotgunutils/sg/Task/13e9f728d4fb0da7fddc52ad0d4667f1/c03bbd4b1d8823fc1223737b3b9bbc27.27 (13 items)>. Size 12432 bytes
    self.__on_sg_data_arrived(sg_data)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_query_model.py", line 1022, in __on_sg_data_arrived
[DEBUG sgtk.stopwatch.tkimp3a0aee2b525d4fc89c43e818c9d4a225.shotgun_model.data_handler] save_cache: 0.002371s
[DEBUG sgtk.env.project.tk-shell.tk-framework-shotgunutils] [SgTaskListingModel] Asynchronous cache save complete.
    self._data_handler.generate_child_nodes(None, root, self._create_item)
  File "/Users/~/Library/Caches/Shotgun/~/p419c67.basic.shell/cfg/install/core/python/tank/log.py", line 514, in wrapper
    response = func(*args, **kwargs)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/data_handler.py", line 272, in generate_child_nodes
    factory_fn(parent_object, data_item)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_model.py", line 623, in _create_item
    self._update_item(item, data_item)
  File "/Users/~/Library/Caches/Shotgun/bundle_cache/app_store/tk-framework-shotgunutils/v5.10.0/python/shotgun_model/shotgun_model.py", line 664, in _update_item
    {"name": data_item.field, "value": data_item.shotgun_data[data_item.field]},
KeyError: 'bad'

Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I would also like to have better error handling for the case you pointed out. Is it possible to invest more time for it?

Also, I think the documentation should be updated as well. Probably this page.

info.yml Outdated
Comment on lines 41 to 42
description: "Controls what fields appear for sorting
"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Controls what fields appear for sorting
"
description: "Controls what fields appear for sorting"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I had intended to add more details there, that was just place holder. I'll update that thanks

@pscadding
Copy link
Contributor Author

Also I wonder if the setting name should not be my tasks specific and then you list the tab under it. That way if we add the sort field to other tabs we wont need to change the setting name.

Comment on lines -1433 to +1442
actions_list[3].setChecked(True)
actions_list[4].setChecked(False)
actions_list[0].setChecked(True)
actions_list[1].setChecked(False)
elif sort_order == "desc":
actions_list[4].setChecked(True)
actions_list[3].setChecked(False)
actions_list[0].setChecked(False)
actions_list[1].setChecked(True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the sort order to the top, it was shown at the bottom of the list. This brings it inline with the web UI.

@julien-lang julien-lang changed the title Ticket/SG-36129 add customized sort fields SG-36129 Add customized sort fields Aug 29, 2024
Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for that @pscadding

@pscadding

This comment was marked as outdated.

@pscadding
Copy link
Contributor Author

We decided not to implement the changes on the SG Utils for better catching. We didn't want to introduce unnecessary risk for the handling of this edge case.

Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants